﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>UpLoadFile</title>
</head>
<body>
    <div>
        <form role="form">
            <div class="form-group">
                已选文件
                <input name="fileName" id="fileName" readonly="readonly" />
                <label for="exampleInputFile">选择文件</label>
                <input id="file_upload" name="file_upload" type="file" class="form-control input-sm">
            </div>
            <a href="javascript:void()" class="btn btn-success btn-md"><span class="glyphicon glyphicon-ok"></span> 提交 </a>
        </form>
        <p id="url"></p>
    </div>



    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script type="text/javascript" src="../Content/uploadify/jquery.uploadify.min.js?v=@DateTime.Now.Ticks"></script>
    <link href="../Css/uploadify.css" rel="stylesheet" />
    <script type="text/javascript">
    //上传文件
    var _attachmentUrl = null;
    $(function () {
        $("#file_upload").uploadify({
            'queueSizeLimit': 1,
            //fileType代表文件类型的值可能有:   Image 、 OtherFile 、 Temp
            'formData': { 'fileType': 'CourseInfo' },
            'buttonText': '请选择上传文件',
            'swf': '../Content/uploadify/uploadify.swf',
            'uploader': '/Base/UpLoad',
            'onUploadSuccess': function (file, data, response) {
                var json = $.parseJSON(data);
                if (json.result) {
                    _attachmentUrl = json.message; //文件保存的地址
                    $("#url").html("返回的路径是:" + _attachmentUrl);
                    $("#fileName").val(file.name);
                }
                else {
                    showTips.open(json.message);
                }
            }
        });
    });


    </script>
</body>
</html>

